/**
 *
 * @author
 *
 */
class HeroZhugeliang extends HeroBase {

    private _heroArm: dragonBones.FastArmature;
    private _heroDisplay: egret.DisplayObjectContainer;

    public constructor() {
        super();

        this.x = 1600;
        this.y = 1150;

        this._heroArm = AniFactory.produce('heroani/zhugeliang/ani.json', 'heroani/zhugeliang/texture.json', 'heroani/zhugeliang/texture.png', 'herozhugeliang');
        this._heroDisplay = this._heroArm.display;

        this._heroDisplay.x = -1000;
        this._heroArm.animation.gotoAndPlay('idle');

        this.addChild(this._heroDisplay);
    }

    public play(onStatusChange?: Function): void {

        var that = this;

        function playAni(name: string,time?: number): void {
            that._heroArm.animation.gotoAndPlay(name,time);
        }

        egret.Tween.get(this._heroDisplay).call(function() {
            playAni('flyup');
        }).to({
            x: -300,
            y: -500,
            scaleX: 1.5,
            scaleY: 1.5
        },1000).call(function() {
            playAni('flydown',0.5);
            onStatusChange && onStatusChange('fall');
        }).to({
            x: 0,
            y: 0,
            scaleX: 1.5,
            scaleY: 1.5
        },1000).call(function() {
            playAni('attack2',0.5);
            setTimeout(function() {
                onStatusChange && onStatusChange('hurt');
            },1800);
        }).wait(2500).call(function() {
            playAni('skill2',0.5);
            setTimeout(function() {
                onStatusChange && onStatusChange('die');
            },2000);
        }).wait(2500).call(function() {
            playAni('idle',0.5);
        }).wait(1500).call(function() {
            playAni('win',0.5);
        }).wait(3260).call(function() {
            onStatusChange && onStatusChange('done');
        });
    }
}
